﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Routing;

namespace Pikapika
{
    public static class RouteDataExtensions
    {
        public static void ProcessOptionalId(this RouteData routeData, string key, Action<int> process)
        {
            if (routeData.Values.ContainsKey(key))
            {
                int id;
                if (int.TryParse((string)routeData.Values[key], out id))
                {
                    process(id);
                }
            }
        }
    }
}